package net.easyjava.test.bean;

import net.easyjava.third.search.annotation.IndexID;
import net.easyjava.tools.BaseBean;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by wxnacy on 16/6/23.
 */
public class Station extends BaseBean implements Comparable<Station> {
    private static final long serialVersionUID = 4694800888691677680L;
    @IndexID
    private long stationId;
    private String stationName;
    private List<Long> lineIdList;
    private long lineId;
    private String lineName;
    private int dis;
    private int type;
    private String lat;
    private String lng;

    public Station() {
    }


    public int getDis() {
        return dis;
    }

    public void setDis(int dis) {
        this.dis = dis;
    }


    public long getLineId() {
        return lineId;
    }

    public void setLineId(long lineId) {
        this.lineId = lineId;
    }

    public String getLineName() {
        return lineName;
    }

    public void setLineName(String lineName) {
        this.lineName = lineName;
    }

    public List<Long> getLineIdList() {
        return lineIdList;
    }

    public void setLineIdList(List<Long> lineIdList) {
        this.lineIdList = lineIdList;
    }

    public void addLineIdList(long lineId){
        List<Long> list = this.lineIdList;
        if(list == null){
            list = new ArrayList<>();
        }
        list.add(lineId);
        this.lineIdList = list;
    }
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public long getStationId() {
        return stationId;
    }

    public void setStationId(long stationId) {
        this.stationId = stationId;
    }

    public String getStationName() {
        return stationName;
    }

    public void setStationName(String stationName) {
        this.stationName = stationName;
    }

    public String getLat() {
        return lat;
    }

    public void setLat(String lat) {
        this.lat = lat;
    }

    public String getLng() {
        return lng;
    }

    public void setLng(String lng) {
        this.lng = lng;
    }

    /**
     * Compares this object with the specified object for order.  Returns a
     * negative integer, zero, or a positive integer as this object is less
     * than, equal to, or greater than the specified object.
     * <p/>
     * <p>The implementor must ensure <tt>sgn(x.compareTo(y)) ==
     * -sgn(y.compareTo(x))</tt> for all <tt>x</tt> and <tt>y</tt>.  (This
     * implies that <tt>x.compareTo(y)</tt> must throw an exception iff
     * <tt>y.compareTo(x)</tt> throws an exception.)
     * <p/>
     * <p>The implementor must also ensure that the relation is transitive:
     * <tt>(x.compareTo(y)&gt;0 &amp;&amp; y.compareTo(z)&gt;0)</tt> implies
     * <tt>x.compareTo(z)&gt;0</tt>.
     * <p/>
     * <p>Finally, the implementor must ensure that <tt>x.compareTo(y)==0</tt>
     * implies that <tt>sgn(x.compareTo(z)) == sgn(y.compareTo(z))</tt>, for
     * all <tt>z</tt>.
     * <p/>
     * <p>It is strongly recommended, but <i>not</i> strictly required that
     * <tt>(x.compareTo(y)==0) == (x.equals(y))</tt>.  Generally speaking, any
     * class that implements the <tt>Comparable</tt> interface and violates
     * this condition should clearly indicate this fact.  The recommended
     * language is "Note: this class has a natural ordering that is
     * inconsistent with equals."
     * <p/>
     * <p>In the foregoing description, the notation
     * <tt>sgn(</tt><i>expression</i><tt>)</tt> designates the mathematical
     * <i>signum</i> function, which is defined to return one of <tt>-1</tt>,
     * <tt>0</tt>, or <tt>1</tt> according to whether the value of
     * <i>expression</i> is negative, zero or positive.
     *
     * @param o the object to be compared.
     * @return a negative integer, zero, or a positive integer as this object
     * is less than, equal to, or greater than the specified object.
     * @throws NullPointerException if the specified object is null
     * @throws ClassCastException   if the specified object's type prevents it
     *                              from being compared to this object.
     */
    @Override
    public int compareTo(Station o) {
        long begin = System.currentTimeMillis();
        int flag = 1;
        if(
//                o.getType() == this.type &&
//                o.getStationId() == this.stationId &&
                o.getLat().equalsIgnoreCase(this.lat) &&
                o.getLng().equalsIgnoreCase(this.lng))
        {
            return 0;
        }
//        if(o.getType() == this.getType()){
//            if(o.getStationId() == this.stationId){
//                if(o.getLat().equalsIgnoreCase(this.lat) && o.getLng().equalsIgnoreCase(this.lng)){
//                    flag = 0;
//                }
//            }else{
//                if(o.getDis()<this.dis){
//                    flag = 1;
//                }else{
//                    flag = -1;
//                }
//            }
//        }else if(o.getType() <this.getType()){
//            flag = 1;
//        }else if(o.getType() > this.getType()){
//            flag =  -1;
//        }
        long end = System.currentTimeMillis();
//        System.out.println("compareto = " + (end - begin));

        return flag;
    }


}
